<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>


<style>
	.hrSt {
		width: 30%; 
		height:0px; 
		border:none; 
		border-top:1px solid #ccc;
		margin-left: 40px;
	}
	.pSty {
		font-size: 15px;
		text-indent: 20px;
		padding-top: 5px
	}
</style>

<div class="module">
    <p class="title">订单列表&nbsp;&nbsp;&nbsp;&nbsp;
    	<span class="searchspan">
            <input type="text" id="key" class="ctr-input ctr-short" value="${key}" placeholder="关键字">&nbsp;
            <button type="button" class="form-button" onclick="searchManager($('#key').val())" style="height: 32px;">查询</button>
    	</span>
    </p>
    <div class="content">
    	
         <table class="table margintop-m">
            <thead>
                <tr>
                	<th>序号</th>
                	<th>订单号</th>
                	<th>车牌号</th>
                	<th>所属车场</th>
                	<th>订单状态</th>
                	<th>金额</th>
                	<th>创建时间</th>
                	<th class="mlen">操作</th>
                </tr>
            </thead>
            <tbody>
            	<c:forEach items="${ordersList }" var="orders" varStatus="i">
            		<tr id='${orders.id }'>
            			<td>${((null==param.pageNo?1:param.pageNo)-1)*param.pageSize+i.index+1 }</td>
            			<td style="width: 125px;">${orders.orderNumber }</td>
            			<td style="width: 125px;">${orders.plateNumber }</td>
            			<td>${orders.parkingName }</td>
            			<td>
            				<c:if test="${orders.status==0 }">计时中</c:if>
            				<c:if test="${orders.status==1 }">等待支付</c:if>
            				<c:if test="${orders.status==2 }">完成</c:if>
            			</td>
            			<td>${orders.amount/100 }</td>
            			<td><fmt:formatDate value="${orders.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
            			<td>
            				<a class="form-button-small editBtn" href="javascript: void(0);" onclick="javascript: getEditPate('${orders.id }');">详情</a>
            				<a class="form-button-small delBtn" href="javascript: void(0);" onclick="javascript: delObject('${orders.id }');">删除</a>
            			</td>
            		</tr>
            	</c:forEach>
            	
            </tbody>
        </table>
		<div id="pagination" class="text_c">${nowpage }</div>
    </div>
</div>



<script type="text/javascript">

function splitStr(pageno_str){
	var pageno_pagesize_str = pageno_str.substring(pageno_str.indexOf("?")+1);
	var pageno_pagesize = pageno_pagesize_str.split("&");
	
	var pageno, arr;
	for(var i=0;i<pageno_pagesize.length;i++){
		arr = pageno_pagesize[i].split("=");
		if(arr[0]=='page_num'){
			pageno = arr[1];
			break;
		}
	}
	
	return pageno;
}


function changePage(currentpage_str) {
	var pageNo = splitStr(currentpage_str);
	getPage(pageNo, false);
	
}


function getPage(pageNo){
	getOrdersList(pageNo);
}



// 新增页
/* function getCreatePage(){
	
	var site = '${null==param.pageNo?1:param.pageNo}';
	
	$.ajax({
        type: "POST",
        url: contextPath + "/web/managerCenter/handlePage",
        dataType: "html",
        data: {'site': site},
        beforeSend: function () {
            $("#maincontent").html("");
            $("#beforeLoading").show();
            timeOutHint();
        },
        success: function (res) {
            if ("" != res) {
                $("#beforeLoading").hide();
                $("#maincontent").html(res);
            }
        }
    });
} */


// 编辑页
function getEditPate(id){
	var site = '${null==param.pageNo?1:param.pageNo}';
	
	$.ajax({
        type: "POST",
        url: contextPath + "/web/orderCenter/getOrders",
        dataType: "html",
        data: {'id': id, 'site': site},
        beforeSend: function () {
            $("#maincontent").html("");
            $("#beforeLoading").show();
            timeOutHint();
        },
        success: function (res) {
            if ("" != res) {
                $("#beforeLoading").hide();
                $("#maincontent").html(res);
            }
        }
    });
}


// 删除对象
function delObject(id){
	
	showConfirm("确定删除此对象吗？", function(){
		$.ajax({
	        type: "POST",
	        url: contextPath + "/web/orderCenter/delOrders",
	        dataType: "json",
	        data: {'id': id},
	        beforeSend: function () {
	            $("#beforeLoading").show();
	            timeOutHint();
	        },
	        success: function (res) {
	            if ("" != res) {
	                $("#beforeLoading").hide();
	                
	                if(res.resData.status){
	                	$('#'+id+'').fadeOut("slow");
	                	getManagerList(${param.pageNo});
	                }
	                
	            }
	        }
	    });
	});
	
}


//查询
function searchManager(key){
	
	$.ajax({
        type: "POST",
        url: contextPath + "/web/orderCenter/getOrdersList",
        dataType: "html",
        data: {'key': key},
        beforeSend: function () {
            $("#maincontent").html("");
            $("#beforeLoading").show();
            timeOutHint();
        },
        success: function (res) {
            if ("" != res) {
                $("#beforeLoading").hide();
                $("#maincontent").html(res);
            }
        },
        error: function(){
        	$("#beforeLoading").hide();
        	failHint();
        }
    });
}


</script>